import {message} from 'antd';
import {formatMessage} from './intl';

export const shipmentValidator = data => {
    //增加判断必填字段
    const emptyErrors = [];
    if(!data || !data.shipmentDate)
        emptyErrors.push(formatMessage({
            id: 'validator.empty.shipmentDate',
            defaultMessage: '出运日期'
        }));
    if(!data || !data.expectArrivalDate)
        emptyErrors.push(formatMessage({
            id: 'validator.empty.expectArrivalDate',
            defaultMessage: '预计到港日期'
        }));
    if(emptyErrors.length > 0) {
        message.warning(`${emptyErrors.join('，')}${formatMessage({
            id: 'validator.required',
            defaultMessage: '必填!'
        })}`);
        return false;
    }
    return true;
};
